<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="display">
        
    </div>
    <input type="button" value="wang" onclick="clk(1)">
    <input type="button" value="ma" onclick="clk(2)">
    <script>
        function f(name,address){
            this.name=name;
            this.address=address;
            this.show=function(){
                document.getElementById("display").innerHTML=
                "name: "+this.name+",address: "+this.address;
            }
        }
        var wang = new f("wang",1020);
        var ma = new f("ma",313);

        function clk(flag){
            if(flag==1) wang.show();
            if(flag==2) ma.show();
        }
    </script>
</body>
</html>